    <?
    

    $total_char = 0;
    $facil = array ();
    $all_attr = array ();
    
//    $this->firephp->log($details->facilities);

    foreach ( $details->facilities as $key => $value ) :
        if ( $value != "" ):

            $filterSTD = new stdClass;
            $filterSTD->key = explode ( ',', $value );
            $filterSTD->title = $key;
            $filterSTD->cnt = strlen ( $value );

            $facil[$key] = $filterSTD;

            $total_char += $filterSTD->cnt;

        endif;

    endforeach;

    $third = round ( floatval ( $total_char / 3 ) );

    sort_attributes ( $facil );

//                    $this->firephp->log ( $facil );
//                    $this->firephp->log ( 'total char: ' . $total_char );
//                    $this->firephp->log ( 'group count: ' . count ( $facil ) );
//                    $this->firephp->log ( 'third count: ' . $third );
?>


<? $total_cnt = 0; ?>

<div class="third">
    <?
        $first = FALSE;
        $group_cnt = 0;
        $counter = 0;
        foreach ( $facil as $key => $value ) :

            $group_cnt +=$value->cnt;

            if ( $group_cnt > $third ):

                if ( $first )
                    break 1;

                $first = TRUE;
            endif;
            ?>

            <ul>
                <li class="section"><?= $key ?>:</li>

                <? foreach ( $value->key as $index => $attr ) : ?>

                    <li><?= $attr ?></li>

                <? endforeach;
                ?>

            </ul>

            <?
            unset ( $facil[$key] );

        endforeach;
        $total_cnt +=$group_cnt;

//                        $facil = array_values ( $facil);
    ?>
</div>

<div class="third">
    <?
        $first = FALSE;
        $group_cnt = 0;
        $counter = 0;
        foreach ( $facil as $key => $value ) :

            $group_cnt +=$value->cnt;

            if ( $group_cnt > $third ):

                if ( $first )
                    break 1;

                $first = TRUE;
            endif;
            ?>

            <ul>
                <li class="section"><?= $key ?>:</li>

                <? foreach ( $value->key as $index => $attr ) : ?>

                    <li><?= $attr ?></li>

                <? endforeach;
                ?>

            </ul>

            <?
            unset ( $facil[$key] );

        endforeach;
        $total_cnt +=$group_cnt;
    ?>

</div>

<div class="third">
    <?
        $first = FALSE;
        $group_cnt = 0;
        $counter = 0;
        foreach ( $facil as $key => $value ) :

            ?>

            <ul>
                <li class="section"><?= $key ?>:</li>

                <? foreach ( $value->key as $index => $attr ) : ?>

                    <li><?= $attr ?></li>

                <? endforeach;
                ?>

            </ul>

            <?
        endforeach;
    ?>

</div>